package com.bmw.newbabytimer;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

/**
 * Created by dss on 14/12/24.
 */
public class GridAdapter extends GoodsAdapter {
    private Context mContext;
    public GridAdapter(Context context) {
        mContext = context;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if (null == convertView) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.grid_items_goods,null);
            viewHolder.goodsImg = (ImageView)convertView.findViewById(R.id.goods_img);
            convertView.setTag(viewHolder);
        }

        if (null == data || data.size() <= i) {
            return convertView;
        }

        viewHolder = (ViewHolder)convertView.getTag();
        viewHolder.goodsImg.setImageDrawable(mContext.getResources().getDrawable(R.drawable.demo_img));
        //LocalFileImageLoader.display(viewHolder.goodsImg, data.get(i).img);

        return convertView;
    }

    static class ViewHolder {
        ImageView goodsImg;
    }
}
